﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TjZheng.Framework;
using TjZheng.Mvc;

namespace TjZheng.SSO.Web.Controllers
{
    public class UserController : TjZhengController
    {
        public virtual ActionResult CreateRedirect(string callback, string userId)
        {
            InvokeResult objInvokeResult = new InvokeResult();
            if (callback.IsNull())
            {
                objInvokeResult.ResultCode = "CallbackNull";
                objInvokeResult.ResultMessage = "回调地址为空";
                return Json(objInvokeResult, JsonRequestBehavior.AllowGet);
            }
            if (userId.IsNull())
            {
                objInvokeResult.ResultCode = "UserIdNull";
                objInvokeResult.ResultMessage = "用户Id为空";
                return Json(objInvokeResult, JsonRequestBehavior.AllowGet);
            }
            //todo：这个过程可以组织加密密钥，验证双方约定的令牌
            callback = callback.AttachUrlParameters(new { userId = userId }).CreateUrlSignature();
            return Redirect(callback);
        }
    }
}
